package model

import (
	"database/sql"
	"time"
)

type ProjectMilestone struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	ProjectId               int64
	Deadline                time.Time
	IsReached               bool
	ReachedDate             sql.NullTime
}

type ProjectProjectStage struct {
	ResCommon
	Active         bool
	Sequence       int
	Name           string
	MailTemplateId int
	Fold           bool
}

type ProjectTaskRecurrence struct {
	ResCommon
	NextRecurrenceDate time.Time
	RecurrenceLeft     int
	RepeatInterval     int
	RepeatUnit         string
	RepeatType         string
	RepeatUntil        time.Time
	RepeatNumber       int
	RepeatOnMonth      string
	RepeatOnYear       string
	Mon                bool
	Tue                bool
	Wed                bool
	Thu                bool
	Fri                bool
	Sat                bool
	Sun                bool
	RepeatDay          string
	RepeatWeek         string
	RepeatWeekday      string
	RepeatMonth        string
}

type ProjectTaskUserRel struct {
	ResCommon
	TaskId  int64
	UserId  int64
	StageId sql.NullInt64
}

type ProjectTaskType struct {
	ResCommon
	Active                    bool
	Name                      string
	Description               string
	Sequence                  int
	LegendBlocked             string
	LegendDone                string
	LegendNormal              string
	MailTemplateId            int
	Fold                      bool
	RatingTemplateId          int
	AutoValidationKanbanState bool
	IsClosed                  bool
	UserId                    int
}

type ProjectUpdate struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	EmailCc                 string
	Name                    string
	Status                  string
	Progress                int
	UserId                  int64
	Description             string
	Date                    time.Time
	ProjectId               int64
}

type ProjectTaskTypeRel struct {
	TypeId    int64
	ProjectId int64
}

type ProjectFavoriteUserRel struct {
	ProjectId int64
	UserId    int64
}

type ProjectProjectProjectTagsRel struct {
	ProjectProjectId int64
	ProjectTagsId    int64
}

type ProjectTags struct {
	ResCommon
	Name  string
	Color int64
}

type ProjectTagsProjectTaskRel struct {
	ProjectTaskId int64
	ProjectTagsId int64
}

type ProjectCollaborator struct {
	ResCommon
	ProjectId int64
	PartnerId int64
}

type ProjectDeleteWizard struct {
	ResCommon
}

type ProjectDeleteWizardProjectProjectRel struct {
	ProjectDeleteWizardId int64
	ProjectProjectId      int64
}

type ProjectTaskTypeDeleteWizard struct {
	ResCommon
}

type ProjectProjectProjectTaskTypeDeleteWizardRel struct {
	ProjectTaskTypeDeleteWizardId int64
	ProjectProjectId              int64
}

type ProjectTaskTypeProjectTaskTypeDeleteWizardRel struct {
	ProjectTaskTypeDeleteWizardId int64
	ProjectTaskTypeId             int64
}

type ProjectShareWizard struct {
	ResCommon
	ResModel          string
	ResId             int64
	Note              string
	AccessMode        string
	DisplayAccessMode bool
}

type ProjectShareWizardResPartnerRel struct {
	ProjectShareWizardId int64
	ResPartnerId         int64
}

type ProjectTagsTable struct {
	ResCompanyId   int64
	DocumentsTagId int64
}

type ProjectProject struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	AliasId                 int64
	AccessToken             sql.NullString
	Name                    string
	Description             sql.NullString
	Active                  bool
	Sequence                int
	PartnerId               sql.NullInt64
	PartnerEmail            sql.NullString
	PartnerPhone            sql.NullString
	CompanyId               int64
	AnalyticAccountId       sql.NullInt64
	LabelTasks              string
	Color                   sql.NullInt64
	UserId                  int64
	User                    ResUsers
	PrivacyVisibility       string
	DateStart               sql.NullTime
	Date                    sql.NullTime
	AllowSubtasks           bool
	AllowRecurringTasks     bool
	AllowTaskDependencies   bool
	RatingRequestDeadline   time.Time
	RatingActive            bool
	RatingStatus            string
	RatingStatusPeriod      string
	StageId                 sql.NullInt64
	LastUpdateId            int64
	LastUpdateStatus        string
	SaleLineId              int
	Tags                    []ProjectTags `gorm:"many2many:project_project_project_tags_rel"`
	Users                   []ResPartner  `gorm:"many2many:project_collaborator;joinForeignKey:project_id;joinReferences:partner_id"`
}

type ProjectTask struct {
	ResCommon
	RatingLastValue         float64
	MessageMainAttachmentId int
	EmailCc                 string
	AccessToken             string
	Active                  bool
	Name                    string
	Description             sql.NullString
	Priority                string
	Sequence                int
	StageId                 int
	KanbanState             string
	DateEnd                 sql.NullTime
	DateAssign              sql.NullTime
	DateDeadline            sql.NullTime
	DateLastStageUpdate     sql.NullTime
	ProjectId               sql.NullInt64
	DisplayProjectId        sql.NullInt64
	MilestoneId             sql.NullInt64
	PlannedHours            float64
	PartnerId               sql.NullInt64
	PartnerEmail            sql.NullString
	PartnerPhone            sql.NullString
	CompanyId               int64
	Color                   sql.NullInt64
	DisplayedImageId        int
	ParentId                sql.NullInt64
	EmailFrom               string
	WorkingHoursOpen        string
	WorkingHoursClose       string
	WorkingDaysOpen         float64
	WorkingDaysClose        float64
	RecurringTask           bool
	RecurrenceId            int
	AnalyticAccountId       sql.NullInt64
	PlannedDateBegin        sql.NullTime
	PlannedDateEnd          sql.NullTime
	SaleOrderId             int
	SaleLineId              int
	Progress                float64
	EffectiveHours          float64
	TotalHoursSpent         float64
	RemainingHours          float64
	Tags                    []ProjectTags `gorm:"many2many:project_tags_project_task_rel"`
	User                    []ResUsers    `gorm:"many2many:project_task_user_rel;joinForeignKey:task_id;joinReferences:user_id"`
}
